﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--During development turn off caching-->
    <meta http-equiv="cache-control" content="max-age=0" />
    <meta http-equiv="cache-control" content="no-cache" />
    <meta http-equiv="expires" content="0" />
    <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
    <meta http-equiv="pragma" content="no-cache" />

    <title></title>

    <script src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js" type="text/javascript"></script>
    
    <script>
        // The initialize function must be run each time a new page is loaded
        (function () {
            Office.initialize = function (reason) {
               //If you need to initialize something you can do so here. 
            };
        })();

            //Notice function needs to be in global namespace
        function writeText(event) {

            //Consult Office.js API reference to see all you can do. This just shows the simplest action. 

            Office.context.document.setSelectedDataAsync("ExecuteFunction Works with Prod Office.js Button ID=" + event.source.id,
                function (asyncResult) {
                    var error = asyncResult.error;
                    if (asyncResult.status === "failed") {
                        //show error. Upcoming displayDialog API will help here.
                    }
                    else {
                        //show success.Upcoming displayDialog API will help here.
                    }
                });
           //Required, call event.completed to let the platform know you are done processing. 
	   event.completed();
        }

    </script>
</head>
<body>
    Function file body is never displayed. 
</body>
</html>
